import { ref } from 'vue'
import { defineStore } from 'pinia'
import { TOKEN } from '../utils/constant'
export const useUserStore = defineStore(
  TOKEN,
  () => {
    const token = ref('')
    const user = ref('')
    const setToken = (newToken) => {
      token.value = newToken
    }
    const setUser = (newUser) => {
      user.value = newUser
    }
    const removeToken = () => {
      token.value = ''
    }
    const removeUser = () => {
      user.value = ''
    }
    return {
      token,
      user,
      setUser,
      setToken,
      removeToken,
      removeUser
    }
  },
  {
    persist: true
  }
)

